﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Content/Master.Master" ValidateRequest="false" Inherits="System.Web.Mvc.ViewPage<SCS.Core.Models.Collection.MenuCollection>" %>
<%@ Import Namespace="SCS.Core" %>
<%@ Import Namespace="SCS.Core.Models" %>
<%@ Import Namespace="SCS.Core.ViewModels" %>
<%@ Import Namespace="SCS.Core.Controllers" %>
<%@ Import Namespace="SCSService" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Chi tiết Menu
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript" src="/ThemeExtends/AdminSkin/js/jquery.flot.js"></script>
    <script type="text/javascript" src="/ThemeExtends/AdminSkin/js/jquery.flot.stack.js"></script>	
    <link rel="stylesheet" type="text/css" href="/Content/smoothness-1.8.13/jquery-ui-1.8.13.custom.css"/>
    <link rel="stylesheet" type="text/css" href="/Content/smoothness-1.8.13/ui.dropdownchecklist.themeroller.css"/>
    <script type="text/javascript" src="/Scripts/jquery-1.6.1.min.js"></script>
    <script type="text/javascript" src="/Scripts/jquery-ui-1.8.13.custom.min.js"></script>
    <script type="text/javascript" src="/Scripts/ui.dropdownchecklist-1.4-min.js"></script>
    <script type="text/javascript" src="/Scripts/ui.dropdownchecklist.js"></script>
    <%--Validator--%>
    <script src="/Scripts/jquery.validate.min.js" type="text/javascript"></script>
    <script src="/Scripts/MicrosoftMvcJQueryValidation.js" type="text/javascript"></script>
    <!--Editor-->
    <link rel="stylesheet" href="/Editor/themes/default/default.css" />
	<link rel="stylesheet" href="/Editor/plugins/code/prettify.css" />
	<script type="text/javascript" charset="utf-8" src="/Editor/kindeditor.js"></script>
	<script type="text/javascript" charset="utf-8" src="/Editor/lang/en_US.js"></script>
	<script type="text/javascript" charset="utf-8" src="/Editor/plugins/code/prettify.js"></script>
	<script type="text/javascript">
	    KindEditor.ready(function (K) {
	        var editor1 = K.create('#FullText', {
	            cssPath: '/Editor/plugins/code/prettify.css',
	            uploadJson: '/Editor/asp.net/upload_json.ashx',
	            fileManagerJson: '/Editor/asp.net/file_manager_json.ashx',
	            allowFileManager: true,
	            afterCreate: function () {
	                var self = this;
	                K.ctrl(document, 13, function () {
	                    self.sync();
	                    K('form[name=example]')[0].submit();
	                });
	                K.ctrl(self.edit.doc, 13, function () {
	                    self.sync();
	                    K('form[name=example]')[0].submit();
	                });
	            }
              
	        });
	        prettyPrint();
	    });
	</script>
      <!--Popup-->
     <link rel="stylesheet" href="/Content/popup.css" />
    <script type="text/javascript">
        $(document).ready(function () {

            //When you click on a link with class of poplight and the href starts with a #  
            $('a.poplight[href^=#]').click(function () {
                var popID = $(this).attr('rel'); //Get Popup Name 
                var popURL = $(this).attr('href'); //Get Popup href to define size 

                //Pull Query & Variables from href URL 
                var query = popURL.split('?');
                var dim = query[1].split('&');
                var popWidth = dim[0].split('=')[1]; //Gets the first query string value 

                //Fade in the Popup and add close button 
                $('#' + popID).fadeIn().css({ 'width': Number(popWidth) }).prepend('<a href="#" class="close"><img src="/Content/images/popup-closeButton.png" class="btn_close" title="Close Window" alt="Close" /></a>');

                //Define margin for center alignment (vertical + horizontal) - we add 80 to the height/width to accomodate for the padding + border width defined in the css 
                var popMargTop = ($('#' + popID).height() + 80) / 2;
                var popMargLeft = ($('#' + popID).width() + 80) / 2;

                //Apply Margin to Popup 
                $('#' + popID).css({
                    'margin-top': -popMargTop,
                    'margin-left': -popMargLeft
                });

                //Fade in Background 
                $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag. 
                $('#facebox_overlay').css({ 'filter': 'alpha(opacity=80)' }).fadeIn(); //Fade in the fade layer  

                return false;
            });


            //Close Popups and Fade Layer 
            $('a.close, #facebox_overlay').live('click', function () { //When clicking on the close or fade layer... 
                $('#facebox_overlay , .popup_block').fadeOut(function () {
                    $('#facebox_overlay, a.close').remove();
                }); //fade them both out 

                return false;
            });


        }); 
    </script>  
   <!--Popup-->
   <script type="text/javascript">
       function getShippment(value) {
           $.ajax({
               type: "POST",
               url: '<%=Url.Action("GetListPupupModule","AdvantageSetting")%>' + '/' + value,
               contentType: "application/json; charset=utf-8",
               dataType: "json",
               success: function (result) {

                   //var innertext = result
                   // $('#TemplateTable').val(result);
//                   $('#TemplateTable').html(result.toString());
//                   var div = $("#TemplateTable");
//                   div.html(result);
               }
           });

       }
   
   </script>
   <script type="text/javascript">
       var HttpRequest = false;

       if (window.XMLHttpRequest) // Internet Explorer
       {
           HttpRequest = new XMLHttpRequest();
       }
       else  // Other browsers  
       {
           HttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
       }


       function GetPageByModuleID(ModuleID, ModuleName) {

           var DivTxtBox = document.getElementById("ItemPage")
           var StringHTML = '<table> <tr class="display"><td align=center> Đường dẫn url</td><td align="center" ></td></tr> ';
           if (!HttpRequest) return;
           if (ModuleID < 0) return;

           var url = '<%=Url.Action("AjaxServer","AdvantageSetting")%>' + '/' + ModuleID;

           HttpRequest.open("GET", url);
           HttpRequest.onreadystatechange = function () {
               if (HttpRequest.readyState == 4 && HttpRequest.status == 200) {
                   var xml = HttpRequest.responseXML;
                   var c = xml.getElementsByTagName("ProStockDetail");


                   for (i = 0; i < c.length; i++) {
                       var id = c[i].attributes[0].value;
                       var pageName = c[i].firstChild.nodeValue;
                       var pageText = c[i].lastChild.nodeValue; ;
                       StringHTML = StringHTML + '<tr> <td>' + ModuleName + "/" + pageName + '</td><td><div class="button themed" class="btn_close" onclick ="SetModule('+ ModuleName +',' + pageName + ')"> Chọn </div> </td> </tr> ';
                   }
                   StringHTML = StringHTML + ' </table>';
                   DivTxtBox.innerHTML = StringHTML;
               }
           }
           HttpRequest.send(null);
       }



     
    </script>
    <script type="text/javascript">

        function SetModule(Module, page) {
            var TextBoxName = document.getElementById("MenuUrl");
            var StringUrl = Module + "/" + page;
            TextBoxName.value = StringUrl;
        }
       function WriteURL(url)
       {
         document.getElementById("MenuUrl").value=url;
       }
    </script>
    <!--End Editor-->
    
   <% Html.EnableClientValidation(); %>
   <% using (Html.BeginForm((bool)ViewData["IsAdd"] ? "SaveAdd" : "SaveEdit", "AdvantageSetting", FormMethod.Post, new { siteGuid = "sendFileForm", language = "sendFileForm", id = "sendFileForm", enctype = "multipart/form-data" }))
            {%>
    <div class="column half fl">
        <div class="box ">
		    <h2 class="box-header"><%=(bool)ViewData["IsAdd"] ? "New Menu" : "Edit Menu"%></h2>
           
		    <div class="box-content">
                
                <label class="form-label"> Tên </label>
                <%= Html.TextBoxFor(m => m.MenuName, new { @class = "form-field full" })%> <span style="color:Red;font-weight:bold"><%= Html.ValidationMessageFor(m => m.MenuName) %></span>
                <br /><br />
                <label class="form-label"> Mô tả </label>
                <%= Html.TextBoxFor(m => m.MenuText, new { @class = "form-field full" })%> <span style="color:Red;font-weight:bold"><%= Html.ValidationMessageFor(m => m.MenuText) %></span>
                <br /><br />
                <label class="form-label" class="button themed"> Đường dẫn </label>
                <div style="width:80%;margin-right:10px;float:left;"><%= Html.TextBoxFor(m => m.MenuUrl, new { @class = "form-field full" })%></div>
                <a href="#?w=600" rel="popup_name" class="poplight" onclick="getShippment(2)" style="float:left;clear:right;"><div class="button themed">Chọn Link</div></a> 
                <div id="popup_name" class="popup_block">                                
                <div id="TemplateTable" style=" width:auto; float:left;" > </div>
                <div id="ItemPage" class="box-content" style="height:500px; overflow:scroll;">
                <%=ViewData["ListTyproduct"]%> 
                <%=ViewData["ListArticleCategory"]%> 
                <%=ViewData["ListStaticArticleCategory"]%>
                </div>

                                                        
                </div>     
                <br /><br />           
                <label class="form-label" style="clear:both;"> Chọn Menu cha</label>
                <%= Html.DropDownListFor(m => m.PartnerMenuId, (SelectList)ViewData["ListParent"], "--Chọn menu--")%>

                <br /><br />
                 <label class="form-label"> Trạng thái </label>
                 <%
                    if (Model.Active == true)
                   {
                   %>
                       
                        <%=Html.CheckBoxFor(m =>m.Active, true)%>
                   <%
                     }
                   else
                   {
                       if ((bool)ViewData["IsAdd"])
                       {
                       %>
                        <%=Html.CheckBoxFor(m=>m.Active,true) %>
                       <%
                       }
                       else
                       { 
                       %>
                        <%=Html.CheckBoxFor(m=>m.Active) %>
                       <%
                       }
                    
                   } 
                    %>
                                  
                 <%=Html.HiddenFor(m=>m.MenuId) %>
                 <%=Html.HiddenFor(m=>m.LanguagesID) %>
                 <%=Html.HiddenFor(m=>m.SiteGuid) %>
                 <%=Html.HiddenFor(m=>m.SortOrder) %>
                 
                 
                 <p>
                <%=ViewData["Result"]%> 
                </p>
                                   
                 <input type="submit" value="" class="button white_input save_input "/> <!--Button Save-->
                 <a class="button white" href="javascript:history.back();"><span class="icon_text cancel"></span>Đóng</a> <!--Button Close-->
               
	        </div>
	    </div>
	     <div class="clear"></div>    
    </div>
    <div class="column half fr">
        <div class="box ">
		<h2 class="box-header"></h2>
		    <div class="box-content">
                
                <label class="form-label"> Ảnh </label>
                <%if (Model.Images != null)
                  {
                      string src = Model.Images;
                       
                           %>
                            
                               <img src="http://paynetvn.com/<%=Model.Images %>" id="imgname" width="150px" alt="" onclick="window.open('/Editor/aspnet/Images.aspx','images',' width=750,height=450,left=150,top=200,toolbar=no,status=0,scrollbars=1,location=0,');" />  
                           <%
                  }
                  else
                  { 
                     %>
                               <img src="/Content/images/noimage.gif" width="130px" id="imgname" alt="" onclick="window.open('/Editor/aspnet/Images.aspx','images',' width=750,height=450,left=150,top=200,toolbar=no,status=0,scrollbars=1,location=0,');" />
                     <%
                  }
                  %>
                  <%=Html.HiddenFor(m=>m.Images) %>
                
            </div>
        </div>
        
	</div>     
     <div class="clear"></div>
       
 
    <% } %>
    
         <script type="text/javascript">
             function getTemModify() {
                 var iframe = document.getElementById("Content_TemplateDetail_html");

                 if (document.all || document.getElementById) {
                     document.getElementById('Content_TemplateDetailValueINOUT').value = iframe.contentWindow.document.body.innerHTML;
                 }
                 else {
                     document.getElementById('Content_TemplateDetailValueINOUT').setAttribute("value", iframe.contentWindow.document.body.innerHTML);
                 }

                 // document.getElementById("btnSaveTemplate").disabled = true;

             }
</script>
</asp:Content>
